package com.miao.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.miao.base.model.PageResult;
import com.miao.dto.MyCourseTableParams;
import com.miao.mapper.XcCourseTablesMapper;
import com.miao.po.XcCourseTables;
import com.miao.pojo.CourseBase;
import com.miao.service.XcCourseTablesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class XcCourseTablesServiceImpl extends ServiceImpl<XcCourseTablesMapper, XcCourseTables> implements XcCourseTablesService {
    @Autowired
    private XcCourseTablesMapper courseTablesMapper;

    //获取我的课程表，分页查询
    @Override
    public PageResult<XcCourseTables> myCourseTable(MyCourseTableParams courseTableParams) {
        int page = courseTableParams.getPage();
        int size = courseTableParams.getSize();
        Page<XcCourseTables> objectPage = new Page<>(page, size);
        LambdaQueryWrapper<XcCourseTables> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(XcCourseTables::getUserId, courseTableParams.getUserId());
//        wrapper.eq(XcCourseTables::getCourseType, courseTableParams.getCourseType());
        Page<XcCourseTables> xcCourseTablesPage = courseTablesMapper.selectPage(objectPage, wrapper);
        return new PageResult<XcCourseTables>(
                xcCourseTablesPage.getRecords(), xcCourseTablesPage.getTotal(), (long) page, (long) size
        );

    }
}
